#ifndef _COMMON_H_
#define _COMMON_H_

/*
 * include header
 */
// standard library
#include <stdlib.h>
#include <math.h>
#include <pthread.h>

// open cv header
#include <opencv/cv.h>
#include <opencv/highgui.h>

#include "Constants.h"
#include "TypeDef.h"

// Define macro functions
#ifndef MAX
#define MAX(a,b)  ((a) > (b) ? (a):(b))
#endif
#ifndef MIN
#define MIN(a,b)  ((a) < (b) ? (a):(b))
#endif
#ifndef ABS
#define ABS(a,b)  (((a)>(b)) ? ((a)-(b)) : ((b)-(a)))
#endif
#ifndef SQUARE
#define SQUARE(x) ((x) * (x))
#endif

#define COUNT_OF_ARRAY(arr)  (sizeof(arr) / sizeof(arr[0]))

#ifdef  DEBUG
#undef  NDEBUG
#include <stdio.h>
#include <assert.h>
#define ERROR(errorMsg)     printf("%s:%s:%d: %s\n", __FILE__, __func__, __LINE__, (errorMsg))
#define ASSERT(expr)        assert(expr)
#else
#define NDEBUG
#define ERROR(errorMsg)
#endif

#endif // _COMMON_H_
